import { useSelector } from "react-redux"

import { ConfigStore } from "@/interface/store/config"

import { IUseOptionsProps } from "./types"

export const useOptions = (props: IUseOptionsProps) => {
	const list = useSelector((state: { config: ConfigStore }) => state.config.allDictLists[props.modal])
	if (!list) return []
	return list.map((item: { label: string; value: string }) => ({
		label: props.strictlyLabel ? item.label : props.func({ id: item.label }),
		value: item.value
	}))
}
